/*
	This file is part of Vajolet.

    Vajolet is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Vajolet is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Vajolet.  If not, see <http://www.gnu.org/licenses/>
*/

#ifndef _move
#define _move
 
#include "vajolet.h"
#include <iostream>
#include <string>


class Move
{
public:
	union
	{
		struct
		{
	unsigned from		:6;
	unsigned to			:6;
	unsigned promotion	:2;
	unsigned flags		:2;
		};
		unsigned short packed;
	};
	
	inline void clear(void){
		packed=0;
	}

	enum SPECIAL_MOVES{
		NULL_MOVE=0,
		NO_MOVE=65,
	};

	enum eflags{
		fnone,
		fpromotion,
		fenpassant,
		fcastle,
	};

	enum epromotion{
		promQueen,
		promRook,
		promBishop,
		promKnight,
	};

	Move(){
		packed=0;
		SEEscore=VALUE_NOT_CACHED;
	}

	std::string display(bool toStdout=true);
	void displayUci(void);
	//void makeMove(void);

	inline char isPawn(int piece) const {
		return (piece&7)==6;
	}
	inline char isblack(int piece) const {
		return piece&8;
	}

	bool isCapture() const;
	bool isCaptureOrPromotion()const ;
	score MVVLVA() const;
	score SEEsign();
	score SEE();
	score gain()const ;

	score SEEscore;

	void copyTo(Move &to){
		to.packed=packed;
		to.SEEscore=SEEscore;
	}; 
};
 
#endif
